package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class Region extends BaseDomain {
    public static final int STATUS_NORMAL=0;//普通
    public static final int STATUS_HOT=1;//推荐

    private String name;

    private Long parentId;

    private Integer state=STATUS_NORMAL;


    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("parentId",parentId);
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }

    public Map<String,Object> changeToMap(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("lazyLoad",true);
        map.put("text",name);
        if(state==STATUS_HOT){
            map.put("tags",new String[]{"推荐"});
        }
        map.put("parentId",parentId);
        map.put("json",getJson());
        return map;
    }

}